/**
 * 项目名：化工企业安全生产信息化管理平台
 * 日期：    2020-03-01 22:19:07
 * Copyright (c) 2015- -版权所有
 */

package com.joysuch.wwyt.edu.entity;

import com.baomidou.mybatisplus.annotation.FieldFill;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.joysuch.wwyt.core.support.AutoSetCommonFieldListener;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.apache.commons.lang3.builder.EqualsBuilder;
import org.apache.commons.lang3.builder.HashCodeBuilder;
import org.hibernate.annotations.SQLDelete;
import org.hibernate.annotations.SQLDeleteAll;
import org.hibernate.annotations.Where;
import org.springframework.data.jpa.domain.support.AuditingEntityListener;

import javax.persistence.*;

import static javax.persistence.GenerationType.IDENTITY;

@EntityListeners({ AuditingEntityListener.class, AutoSetCommonFieldListener.class })
@Entity
@Table(name = "wwyt_edu_courseware")
@SQLDelete(sql = "update wwyt_edu_courseware set DELETE_FLAG = '1' where id= ?")
@SQLDeleteAll(sql = "update wwyt_edu_courseware set DELETE_FLAG = '1' where id= ?")
@Where(clause = "DELETE_FLAG = '0'")
@Data
@TableName("wwyt_edu_courseware")
public class EduCourseware implements java.io.Serializable {

    // columns START
    // ID
    @Id
    @GeneratedValue(strategy = IDENTITY)
    @Column(name = "ID", unique = true, nullable = false)
    private Long id;

    // 编号
    @Column(name = "CODE", length = 10)
    private String code;

    // 名称
    @Column(name = "NAME", length = 100)
    private String name;

    // 分类ID
    @Column(name = "TYPE_ID")
    private Long typeId;

    // 格式
    @Column(name = "FORMAT", length = 10)
    private String format;

    // 附件ID
    @Column(name = "ATTACHMENT_ID")
    private Long attachmentId;

    // 封面ID
    @Column(name = "COVER_ID")
    private Long coverId;

    // 状态
    @Column(name = "STATE")
    private Byte state;

    // 创建人
    @org.springframework.data.annotation.CreatedBy
    @Column(name = "CREATE_BY")
    private Long createBy;

    // 创建时间
    @org.springframework.data.annotation.CreatedDate
    @Column(name = "CREATE_TIME")
    private java.util.Date createTime;

    // 更新人
    @org.springframework.data.annotation.LastModifiedBy
    @Column(name = "UPDATE_BY")
    private Long updateBy;

    // 更新时间
    @org.springframework.data.annotation.LastModifiedDate
    @Column(name = "UPDATE_TIME")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private java.util.Date updateTime;

    // 删除标记
    @Column(name = "DELETE_FLAG", length = 2)
    private String deleteFlag;

    // 组织机构代码
    @Column(name = "ORG_CODE", length = 100)
    private String orgCode;

    // 租户
    @Column(name = "TENENT_ID")
    private Long tenentId;

    @Column(name = "CREATE_USER_NAME", length = 20)
    private String createUserName;
    // columns END
    @Column(name = "AUDIT_MSG")
    private String auditMsg;

    // 文档类型
    @Column(name = "DOC_TYPE", length = 5)
    private String docType;

    @ApiModelProperty("学习时长-分")
    private Integer minute;
    @ApiModelProperty("学习时长-秒")
    private Integer second;


    public int hashCode() {
        return new HashCodeBuilder().append(getId()).toHashCode();
    }

    public boolean equals(Object obj) {
        if (obj instanceof EduCourseware == false)
            return false;
        if (this == obj)
            return true;
        EduCourseware other = (EduCourseware) obj;
        return new EqualsBuilder().append(getId(), other.getId()).isEquals();
    }
}
